﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Net.Sockets;
using System.Net;

using System.Threading;
using System.Text;

namespace modOperadora.Coneccion
{
    class CCliente
    {
        //start
        public CCliente (string server, int _puerto)
        {
            try
            {
                Servidor = IPAddress.Parse(server);
                puerto = _puerto;
                remotoEP = new IPEndPoint(Servidor, puerto);
                sockCliente = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)

            }
            catch (Exception e)
            {
                string lala = e.ToString();
            }
        }

        //Running
        public void Run()
        {
            try
            {
                sockCliente.Connect(remotoEP);
            }
            catch (Exception e)
            {
                string lala = e.ToString();
            }
        }


        //Closed
        public void Close()
        {
            sockCliente.Shutdown(SocketShutdown.Both);
            sockCliente.Close();
        }

        ~CCliente()
        {
            Close();
        }


        public byte[] callToSv (byte[] paq)
        {
            byte[] respuesta;
            try
            {

            }
            catch (Exception e)
            {
                string lala = e.ToString();
            }

            return respuesta;
        }

        //Datos a redefinir.
        public int puerto { get; set; }
        public IPAddress Servidor { get; set; }

        //Datos Procesados redefinidos
        private Socket cliente;
        private IPEndPoint remotoEP;
        private Socket sockCliente;


        //Callback's
    }
}
